package com.aisile.admin.controller.v1;

import com.aisile.admin.service.AdSensitiveService;
import com.aisile.api.admin.AdSensitiveControllerApi;
import com.aisile.model.admin.dtos.SensitiveDto;
import com.aisile.model.admin.pojos.AdSensitive;
import com.aisile.model.common.dtos.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@CrossOrigin
@RequestMapping("/v1/sensitive")
@Api(value = "敏感词管理" ,tags = "sensitive", description = "敏感词管理API")
public class AdSensitiveController implements AdSensitiveControllerApi {
    @Autowired
    private AdSensitiveService adSensitiveService;

    @Override
    @PostMapping("/list")
    @ApiOperation(value = "查询敏感词列表", notes = "根据分页条件查询敏感词列表")
    @ApiImplicitParam(name = "dto", value = "分页查询条件", dataType = "SensitiveDto")
    public ResponseResult list(@RequestBody SensitiveDto dto) {
        return adSensitiveService.list(dto);
    }

    @Override
    @PostMapping("/save")
    @ApiOperation(value = "添加敏感词")
    @ApiImplicitParam(name = "adSensitive", value = "添加敏感词", dataType = "AdSensitive")
    public ResponseResult save(@RequestBody AdSensitive adSensitive) {
        return adSensitiveService.insert(adSensitive);
    }

    @Override
    @PutMapping("/update")
    @ApiOperation(value = "修改敏感词")
    @ApiImplicitParam(name = "adSensitive", value = "修改敏感词", dataType = "AdSensitive")
    public ResponseResult update(@RequestBody AdSensitive adSensitive) {
        return adSensitiveService.update(adSensitive);
    }

    @Override
    @DeleteMapping("/deleteById/{id}")
    @ApiOperation(value = "删除敏感词")
    @ApiImplicitParam(name = "adSensitive", value = "删除敏感词", dataType = "AdSensitive")
    public ResponseResult deleteById(@PathVariable("id") Integer id) {
        return adSensitiveService.deleteById(id);
    }

    @Override
    @GetMapping("/findById/{id}")
    @ApiOperation(value = "根据id查询敏感词")
    @ApiImplicitParam(name = "adSensitive", value = "根据id查询敏感词", dataType = "AdSensitive")
    public ResponseResult findById(@PathVariable("id") Integer id) {
        return adSensitiveService.findById(id);
    }
}
